package pl.webshoptest;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.AssertJUnit;

public class Page {

        protected int Timeout = 30;
        protected WebDriver driver;
 
        public Page(WebDriver driver) {
                this.driver = driver;
        }

        protected WebElement findElement(String field) {  
                return driver.findElement(By.xpath(field));
        }
  
        protected WebElement findElementByLinkText(String linkText) {
            return driver.findElement(By.partialLinkText(linkText));
        }
               
        protected void insertText(String field, String text){
                WebElement element = findElement(field);
                element.clear();
                element.sendKeys(text);        
        }     
       
        protected void assertLinkIsOnPage(String text) {
                AssertJUnit.assertEquals(text, driver.findElement(By.linkText(text)).getText());
        }
       
        protected void chooseAddress(String link) {
            driver.get(link);
        }

        protected void click(By by) {
            driver.findElement(by).click();
        }
   
        protected void clickXPath(String field) {
            driver.findElement(By.xpath(field)).click();
        }

}


